<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">

	<title>Class Format</title>

	<link rel="stylesheet" href="resources/style.css?e99947befd7bf673c6b43ff75e9e0f170c88a60e">

</head>

<body>
<div id="left">
	<div id="menu">
		<a href="index.html" title="Overview"><span>Overview</span></a>


		<div id="groups">
				<h3>Packages</h3>
			<ul>
				<li>
					<a href="package-CodeIgniter.html">
						CodeIgniter<span></span>
					</a>

						<ul>
				<li>
					<a href="package-CodeIgniter.Libraries.html">
						Libraries					</a>

						</li>
				<li>
					<a href="package-CodeIgniter.Rest.html">
						Rest					</a>

						</li>
							</ul></li>
				<li>
					<a href="package-None.html">
						None					</a>

						</li>
			</ul>
		</div>

		<hr>


		<div id="elements">
			<h3>Classes</h3>
			<ul>
				<li class="active"><a href="class-Format.html">Format</a></li>
				<li><a href="class-Rest_server.html">Rest_server</a></li>
				<li><a href="class-Welcome.html">Welcome</a></li>
			</ul>





		</div>
	</div>
</div>

<div id="splitter"></div>

<div id="right">
<div id="rightInner">
	<form id="search">
		<input type="hidden" name="cx" value="">
		<input type="hidden" name="ie" value="UTF-8">
		<input type="text" name="q" class="text" placeholder="Search">
	</form>

	<div id="navigation">
		<ul>
			<li>
				<a href="index.html" title="Overview"><span>Overview</span></a>
			</li>
			<li>
<span>Package</span>			</li>
			<li class="active">
<span>Class</span>			</li>
		</ul>
		<ul>
		</ul>
		<ul>
		</ul>
	</div>

<div id="content" class="class">
	<h1>Class Format</h1>


	<div class="description">
	<p>Format class
Help convert between various formats such as XML, JSON, CSV, etc.</p>
	</div>









	<div class="info">
		
		
		
		

				<b>License:</b>
				<a href="http://www.dbad-license.org/">http://www.dbad-license.org/</a><br>
				<b>Author:</b>
				Phil Sturgeon, Chris Kacerguis, @softwarespot<br>
			<b>Located at</b> <a href="source-class-Format.html#5-531" title="Go to source code">libraries/Format.php</a>
		<br>
	</div>



	<table class="summary methods" id="methods">
	<caption>Methods summary</caption>
	<tr data-order="__construct" id="___construct">

		<td class="attributes"><code>
			 public 

			
			
			</code>
		</td>

		<td class="name"><div>
		<a class="anchor" href="#___construct">#</a>
		<code><a href="source-class-Format.html#76-106" title="Go to source code">__construct</a>( <span>null <var>$data</var> = <span class="php-keyword1">NULL</span></span>, <span>null <var>$from_type</var> = <span class="php-keyword1">NULL</span></span> )</code>

		<div class="description short">
			<p>DO NOT CALL THIS DIRECTLY, USE factory()</p>
		</div>

		<div class="description detailed hidden">
			<p>DO NOT CALL THIS DIRECTLY, USE factory()</p>


				<h4>Parameters</h4>
				<div class="list"><dl>
					<dt><var>$data</var></dt>
					<dd></dd>
					<dt><var>$from_type</var></dt>
					<dd></dd>
				</dl></div>


				<h4>Throws</h4>
				<div class="list">
					Exception
				</div>



		</div>
		</div></td>
	</tr>
	<tr data-order="factory" id="_factory">

		<td class="attributes"><code>
			 public 

			object
			
			</code>
		</td>

		<td class="name"><div>
		<a class="anchor" href="#_factory">#</a>
		<code><a href="source-class-Format.html#108-123" title="Go to source code">factory</a>( <span>mixed <var>$data</var></span>, <span>string <var>$from_type</var> = <span class="php-keyword1">NULL</span></span> )</code>

		<div class="description short">
			<p>Create an instance of the format class
e.g: echo $this->format->factory(['foo' => 'bar'])->to_csv();</p>
		</div>

		<div class="description detailed hidden">
			<p>Create an instance of the format class
e.g: echo $this->format->factory(['foo' => 'bar'])->to_csv();</p>


				<h4>Parameters</h4>
				<div class="list"><dl>
					<dt><var>$data</var></dt>
					<dd>Data to convert/parse</dd>
					<dt><var>$from_type</var></dt>
					<dd>Type to convert from e.g. json, csv, html</dd>
				</dl></div>

				<h4>Returns</h4>
				<div class="list">
					object<br>Instance of the format class
				</div>




		</div>
		</div></td>
	</tr>
	<tr data-order="to_array" id="_to_array">

		<td class="attributes"><code>
			 public 

			array
			
			</code>
		</td>

		<td class="name"><div>
		<a class="anchor" href="#_to_array">#</a>
		<code><a href="source-class-Format.html#127-163" title="Go to source code">to_array</a>( <span>mixed|null <var>$data</var> = <span class="php-keyword1">NULL</span></span> )</code>

		<div class="description short">
			<p>Format data as an array</p>
		</div>

		<div class="description detailed hidden">
			<p>Format data as an array</p>


				<h4>Parameters</h4>
				<div class="list"><dl>
					<dt><var>$data</var></dt>
					<dd><p>Optional data to pass, so as to override the data passed
to the constructor</p></dd>
				</dl></div>

				<h4>Returns</h4>
				<div class="list">
					array<br>Data parsed as an array; otherwise, an empty array
				</div>




		</div>
		</div></td>
	</tr>
	<tr data-order="to_xml" id="_to_xml">

		<td class="attributes"><code>
			 public 

			mixed
			
			</code>
		</td>

		<td class="name"><div>
		<a class="anchor" href="#_to_xml">#</a>
		<code><a href="source-class-Format.html#165-248" title="Go to source code">to_xml</a>( <span>mixed|null <var>$data</var> = <span class="php-keyword1">NULL</span></span>, <span>null <var>$structure</var> = <span class="php-keyword1">NULL</span></span>, <span>string <var>$basenode</var> = <span class="php-quote">'xml'</span></span> )</code>

		<div class="description short">
			<p>Format data as XML</p>
		</div>

		<div class="description detailed hidden">
			<p>Format data as XML</p>


				<h4>Parameters</h4>
				<div class="list"><dl>
					<dt><var>$data</var></dt>
					<dd><p>Optional data to pass, so as to override the data passed
to the constructor</p></dd>
					<dt><var>$structure</var></dt>
					<dd></dd>
					<dt><var>$basenode</var></dt>
					<dd></dd>
				</dl></div>

				<h4>Returns</h4>
				<div class="list">
					mixed
				</div>




		</div>
		</div></td>
	</tr>
	<tr data-order="to_html" id="_to_html">

		<td class="attributes"><code>
			 public 

			mixed
			
			</code>
		</td>

		<td class="name"><div>
		<a class="anchor" href="#_to_html">#</a>
		<code><a href="source-class-Format.html#250-300" title="Go to source code">to_html</a>( <span>mixed|null <var>$data</var> = <span class="php-keyword1">NULL</span></span> )</code>

		<div class="description short">
			<p>Format data as HTML</p>
		</div>

		<div class="description detailed hidden">
			<p>Format data as HTML</p>


				<h4>Parameters</h4>
				<div class="list"><dl>
					<dt><var>$data</var></dt>
					<dd><p>Optional data to pass, so as to override the data passed
to the constructor</p></dd>
				</dl></div>

				<h4>Returns</h4>
				<div class="list">
					mixed
				</div>




		</div>
		</div></td>
	</tr>
	<tr data-order="to_csv" id="_to_csv">

		<td class="attributes"><code>
			 public 

			string
			
			</code>
		</td>

		<td class="name"><div>
		<a class="anchor" href="#_to_csv">#</a>
		<code><a href="source-class-Format.html#302-389" title="Go to source code">to_csv</a>( <span>mixed|null <var>$data</var> = <span class="php-keyword1">NULL</span></span>, <span>string <var>$delimiter</var> = <span class="php-quote">','</span></span>, <span>string <var>$enclosure</var> = <span class="php-quote">'&quot;'</span></span> )</code>

		<div class="description short">
			
		</div>

		<div class="description detailed hidden">
			


				<h4>Parameters</h4>
				<div class="list"><dl>
					<dt><var>$data</var></dt>
					<dd><p>Optional data to pass, so as to override the data passed
to the constructor</p></dd>
					<dt><var>$delimiter</var></dt>
					<dd><p>The optional delimiter parameter sets the field
delimiter (one character only). NULL will use the default value (,)</p></dd>
					<dt><var>$enclosure</var></dt>
					<dd><p>The optional enclosure parameter sets the field
enclosure (one character only). NULL will use the default value (")</p></dd>
				</dl></div>

				<h4>Returns</h4>
				<div class="list">
					string<br>A csv string
				</div>


				<h4>Link</h4>
				<div class="list">
						<a href="http://www.metashock.de/2014/02/create-csv-file-in-memory-php/">http://www.metashock.de/2014/02/create-csv-file-in-memory-php/</a><br>
				</div>


		</div>
		</div></td>
	</tr>
	<tr data-order="to_json" id="_to_json">

		<td class="attributes"><code>
			 public 

			string
			
			</code>
		</td>

		<td class="name"><div>
		<a class="anchor" href="#_to_json">#</a>
		<code><a href="source-class-Format.html#391-427" title="Go to source code">to_json</a>( <span>mixed|null <var>$data</var> = <span class="php-keyword1">NULL</span></span> )</code>

		<div class="description short">
			<p>Encode data as json</p>
		</div>

		<div class="description detailed hidden">
			<p>Encode data as json</p>


				<h4>Parameters</h4>
				<div class="list"><dl>
					<dt><var>$data</var></dt>
					<dd><p>Optional data to pass, so as to override the data passed
to the constructor</p></dd>
				</dl></div>

				<h4>Returns</h4>
				<div class="list">
					string<br>Json representation of a value
				</div>




		</div>
		</div></td>
	</tr>
	<tr data-order="to_serialized" id="_to_serialized">

		<td class="attributes"><code>
			 public 

			string
			
			</code>
		</td>

		<td class="name"><div>
		<a class="anchor" href="#_to_serialized">#</a>
		<code><a href="source-class-Format.html#429-446" title="Go to source code">to_serialized</a>( <span>mixed|null <var>$data</var> = <span class="php-keyword1">NULL</span></span> )</code>

		<div class="description short">
			<p>Encode data as a serialized array</p>
		</div>

		<div class="description detailed hidden">
			<p>Encode data as a serialized array</p>


				<h4>Parameters</h4>
				<div class="list"><dl>
					<dt><var>$data</var></dt>
					<dd><p>Optional data to pass, so as to override the data passed
to the constructor</p></dd>
				</dl></div>

				<h4>Returns</h4>
				<div class="list">
					string<br>Serialized data
				</div>




		</div>
		</div></td>
	</tr>
	<tr data-order="to_php" id="_to_php">

		<td class="attributes"><code>
			 public 

			mixed
			
			</code>
		</td>

		<td class="name"><div>
		<a class="anchor" href="#_to_php">#</a>
		<code><a href="source-class-Format.html#448-465" title="Go to source code">to_php</a>( <span>mixed|null <var>$data</var> = <span class="php-keyword1">NULL</span></span> )</code>

		<div class="description short">
			<p>Format data using a PHP structure</p>
		</div>

		<div class="description detailed hidden">
			<p>Format data using a PHP structure</p>


				<h4>Parameters</h4>
				<div class="list"><dl>
					<dt><var>$data</var></dt>
					<dd><p>Optional data to pass, so as to override the data passed
to the constructor</p></dd>
				</dl></div>

				<h4>Returns</h4>
				<div class="list">
					mixed<br>String representation of a variable
				</div>




		</div>
		</div></td>
	</tr>
	<tr data-order="_from_xml" id="__from_xml">

		<td class="attributes"><code>
			 protected 

			SimpleXMLElement
			
			</code>
		</td>

		<td class="name"><div>
		<a class="anchor" href="#__from_xml">#</a>
		<code><a href="source-class-Format.html#469-476" title="Go to source code">_from_xml</a>( <span> <var>$data</var></span> )</code>

		<div class="description short">
			
		</div>

		<div class="description detailed hidden">
			


				<h4>Parameters</h4>
				<div class="list"><dl>
					<dt><var>$data</var></dt>
					<dd>string</dd>
				</dl></div>

				<h4>Returns</h4>
				<div class="list">
					SimpleXMLElement<br>XML element object; otherwise, empty array
				</div>




		</div>
		</div></td>
	</tr>
	<tr data-order="_from_csv" id="__from_csv">

		<td class="attributes"><code>
			 protected 

			array
			
			</code>
		</td>

		<td class="name"><div>
		<a class="anchor" href="#__from_csv">#</a>
		<code><a href="source-class-Format.html#478-502" title="Go to source code">_from_csv</a>( <span>string <var>$data</var></span>, <span>string <var>$delimiter</var> = <span class="php-quote">','</span></span>, <span>string <var>$enclosure</var> = <span class="php-quote">'&quot;'</span></span> )</code>

		<div class="description short">
			
		</div>

		<div class="description detailed hidden">
			


				<h4>Parameters</h4>
				<div class="list"><dl>
					<dt><var>$data</var></dt>
					<dd>CSV string</dd>
					<dt><var>$delimiter</var></dt>
					<dd><p>The optional delimiter parameter sets the field
delimiter (one character only). NULL will use the default value (,)</p></dd>
					<dt><var>$enclosure</var></dt>
					<dd><p>The optional enclosure parameter sets the field
enclosure (one character only). NULL will use the default value (")</p></dd>
				</dl></div>

				<h4>Returns</h4>
				<div class="list">
					array<br><p>A multi-dimensional array with the outer array being the number of rows
and the inner arrays the individual fields</p>
				</div>




		</div>
		</div></td>
	</tr>
	<tr data-order="_from_json" id="__from_json">

		<td class="attributes"><code>
			 protected 

			mixed
			
			</code>
		</td>

		<td class="name"><div>
		<a class="anchor" href="#__from_json">#</a>
		<code><a href="source-class-Format.html#504-511" title="Go to source code">_from_json</a>( <span> <var>$data</var></span> )</code>

		<div class="description short">
			
		</div>

		<div class="description detailed hidden">
			


				<h4>Parameters</h4>
				<div class="list"><dl>
					<dt><var>$data</var></dt>
					<dd>json string</dd>
				</dl></div>

				<h4>Returns</h4>
				<div class="list">
					mixed<br>Decoded json string with leading and trailing whitespace removed
				</div>




		</div>
		</div></td>
	</tr>
	<tr data-order="_from_serialize" id="__from_serialize">

		<td class="attributes"><code>
			 protected 

			mixed
			
			</code>
		</td>

		<td class="name"><div>
		<a class="anchor" href="#__from_serialize">#</a>
		<code><a href="source-class-Format.html#513-520" title="Go to source code">_from_serialize</a>( <span>string <var>$data</var></span> )</code>

		<div class="description short">
			
		</div>

		<div class="description detailed hidden">
			


				<h4>Parameters</h4>
				<div class="list"><dl>
					<dt><var>$data</var></dt>
					<dd>to unserialized</dd>
				</dl></div>

				<h4>Returns</h4>
				<div class="list">
					mixed<br>Unserialized data
				</div>




		</div>
		</div></td>
	</tr>
	<tr data-order="_from_php" id="__from_php">

		<td class="attributes"><code>
			 protected 

			string
			
			</code>
		</td>

		<td class="name"><div>
		<a class="anchor" href="#__from_php">#</a>
		<code><a href="source-class-Format.html#522-529" title="Go to source code">_from_php</a>( <span> <var>$data</var></span> )</code>

		<div class="description short">
			
		</div>

		<div class="description detailed hidden">
			


				<h4>Parameters</h4>
				<div class="list"><dl>
					<dt><var>$data</var></dt>
					<dd>to trim leading and trailing whitespace</dd>
				</dl></div>

				<h4>Returns</h4>
				<div class="list">
					string<br>Data with leading and trailing whitespace removed
				</div>




		</div>
		</div></td>
	</tr>
	</table>








	<table class="summary constants" id="constants">
	<caption>Constants summary</caption>
	<tr data-order="ARRAY_FORMAT" id="ARRAY_FORMAT">

		<td class="attributes"><code>string</code></td>
		<td class="name">
			<code>
				<a href="source-class-Format.html#14-17" title="Go to source code"><b>ARRAY_FORMAT</b></a>
			</code>

			<div class="description short">
				<p>Array output format</p>
			</div>

			<div class="description detailed hidden">
				<p>Array output format</p>

			</div>
		</td>
		<td class="value">
			<div>
				<a href="#ARRAY_FORMAT" class="anchor">#</a>
				<code><span class="php-quote">'array'</span></code>
			</div>
		</td>
	</tr>
	<tr data-order="CSV_FORMAT" id="CSV_FORMAT">

		<td class="attributes"><code>string</code></td>
		<td class="name">
			<code>
				<a href="source-class-Format.html#19-22" title="Go to source code"><b>CSV_FORMAT</b></a>
			</code>

			<div class="description short">
				<p>Comma Separated Value (CSV) output format</p>
			</div>

			<div class="description detailed hidden">
				<p>Comma Separated Value (CSV) output format</p>

			</div>
		</td>
		<td class="value">
			<div>
				<a href="#CSV_FORMAT" class="anchor">#</a>
				<code><span class="php-quote">'csv'</span></code>
			</div>
		</td>
	</tr>
	<tr data-order="JSON_FORMAT" id="JSON_FORMAT">

		<td class="attributes"><code>string</code></td>
		<td class="name">
			<code>
				<a href="source-class-Format.html#24-27" title="Go to source code"><b>JSON_FORMAT</b></a>
			</code>

			<div class="description short">
				<p>Json output format</p>
			</div>

			<div class="description detailed hidden">
				<p>Json output format</p>

			</div>
		</td>
		<td class="value">
			<div>
				<a href="#JSON_FORMAT" class="anchor">#</a>
				<code><span class="php-quote">'json'</span></code>
			</div>
		</td>
	</tr>
	<tr data-order="HTML_FORMAT" id="HTML_FORMAT">

		<td class="attributes"><code>string</code></td>
		<td class="name">
			<code>
				<a href="source-class-Format.html#29-32" title="Go to source code"><b>HTML_FORMAT</b></a>
			</code>

			<div class="description short">
				<p>HTML output format</p>
			</div>

			<div class="description detailed hidden">
				<p>HTML output format</p>

			</div>
		</td>
		<td class="value">
			<div>
				<a href="#HTML_FORMAT" class="anchor">#</a>
				<code><span class="php-quote">'html'</span></code>
			</div>
		</td>
	</tr>
	<tr data-order="PHP_FORMAT" id="PHP_FORMAT">

		<td class="attributes"><code>string</code></td>
		<td class="name">
			<code>
				<a href="source-class-Format.html#34-37" title="Go to source code"><b>PHP_FORMAT</b></a>
			</code>

			<div class="description short">
				<p>PHP output format</p>
			</div>

			<div class="description detailed hidden">
				<p>PHP output format</p>

			</div>
		</td>
		<td class="value">
			<div>
				<a href="#PHP_FORMAT" class="anchor">#</a>
				<code><span class="php-quote">'php'</span></code>
			</div>
		</td>
	</tr>
	<tr data-order="SERIALIZED_FORMAT" id="SERIALIZED_FORMAT">

		<td class="attributes"><code>string</code></td>
		<td class="name">
			<code>
				<a href="source-class-Format.html#39-42" title="Go to source code"><b>SERIALIZED_FORMAT</b></a>
			</code>

			<div class="description short">
				<p>Serialized output format</p>
			</div>

			<div class="description detailed hidden">
				<p>Serialized output format</p>

			</div>
		</td>
		<td class="value">
			<div>
				<a href="#SERIALIZED_FORMAT" class="anchor">#</a>
				<code><span class="php-quote">'serialized'</span></code>
			</div>
		</td>
	</tr>
	<tr data-order="XML_FORMAT" id="XML_FORMAT">

		<td class="attributes"><code>string</code></td>
		<td class="name">
			<code>
				<a href="source-class-Format.html#44-47" title="Go to source code"><b>XML_FORMAT</b></a>
			</code>

			<div class="description short">
				<p>XML output format</p>
			</div>

			<div class="description detailed hidden">
				<p>XML output format</p>

			</div>
		</td>
		<td class="value">
			<div>
				<a href="#XML_FORMAT" class="anchor">#</a>
				<code><span class="php-quote">'xml'</span></code>
			</div>
		</td>
	</tr>
	<tr data-order="DEFAULT_FORMAT" id="DEFAULT_FORMAT">

		<td class="attributes"><code>string</code></td>
		<td class="name">
			<code>
				<a href="source-class-Format.html#49-52" title="Go to source code"><b>DEFAULT_FORMAT</b></a>
			</code>

			<div class="description short">
				<p>Default format of this class</p>
			</div>

			<div class="description detailed hidden">
				<p>Default format of this class</p>

			</div>
		</td>
		<td class="value">
			<div>
				<a href="#DEFAULT_FORMAT" class="anchor">#</a>
				<code><code><a href="class-Format.html#JSON_FORMAT">Format::<b>JSON_FORMAT</b></a></code></code>
			</div>
		</td>
	</tr>
	</table>




	<table class="summary properties" id="properties">
	<caption>Properties summary</caption>
	<tr data-order="_data" id="$_data">
		<td class="attributes"><code>
			protected  
			mixed
		</code></td>

		<td class="name">
				<a href="source-class-Format.html#61-66" title="Go to source code"><var>$_data</var></a>

			<div class="description short">
				<p>Data to parse</p>
			</div>

			<div class="description detailed hidden">
				<p>Data to parse</p>

			</div>
		</td>
		<td class="value">
			<div>
				<a href="#$_data" class="anchor">#</a>
				<code>[]</code>
			</div>
		</td>
	</tr>
	<tr data-order="_from_type" id="$_from_type">
		<td class="attributes"><code>
			protected  
			string
		</code></td>

		<td class="name">
				<a href="source-class-Format.html#68-73" title="Go to source code"><var>$_from_type</var></a>

			<div class="description short">
				<p>Type to convert from</p>
			</div>

			<div class="description detailed hidden">
				<p>Type to convert from</p>

			</div>
		</td>
		<td class="value">
			<div>
				<a href="#$_from_type" class="anchor">#</a>
				<code><span class="php-keyword1">NULL</span></code>
			</div>
		</td>
	</tr>
	</table>






</div>

	<div id="footer">
		 API documentation generated by <a href="http://apigen.org">ApiGen</a>
	</div>
</div>
</div>
<script src="resources/combined.js"></script>
<script src="elementlist.js"></script>
</body>
</html>
